package com.oceansoft.mobile.econsole.modules.message.entity;

import java.lang.reflect.Field;
import java.util.TreeMap;

public class ErrorCode {

    protected static TreeMap<Integer, String> _map;
    public static final int UnDefinedServerError = -1;
    public static final int UnDefinedClientError = -2;
    public static final int UnDefinedOtherError = -3;
    public static final int UnDefinedDatabaseError = -4;
    public static final int ParameterError = -5;
    public static final int NotImplementCode = -6;
    public static final int UnDefinedMongoError = -7;
    public static final int SysOutOfMemoryError = -8;
    public static final int SysConfigError = -9;
    public static final int ExceptionMobile = -10;
    public static final int ExceptionWeb = -11;
    public static final int ExceptionText = -12;
    public static final int ExceptionIgnoreError = -13;
    public static final int DatabaseDuplicateKey = -101;
    public static final int DatabaseLengthLimit = -102;
    public static final int DatabaseIntegrityConstraintViolation = -103;
    public static final int AndroidJsonParseException = -801;

    static {
        ErrorCode ec = new ErrorCode();
        _map = new TreeMap();
        for (Field field : ErrorCode.class.getFields())
            try {
                _map.put(field.getInt(ec), field.getName());
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
    }

    public static String getFieldName(int errorCode) {
        return (String) _map.get(Integer.valueOf(errorCode));
    }

    public static String getLangString(int code) {
        return "cn.huhoo.ErrorCode" + String.valueOf(code);
    }
}